package com.wms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wms.dto.SupplierDto;
import com.wms.mapper.SupplierMapper;
import com.wms.pojo.PageResult;
import com.wms.pojo.Supplier;
import com.wms.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> implements SupplierService {
    @Autowired
    private SupplierMapper supplierMapper;
    @Override
    public PageResult getPage(SupplierDto dto) {
        PageHelper.startPage(dto.getPage(),dto.getPageSize());
        List<Supplier> list = supplierMapper.getPage(dto);
        Page<Supplier> supplierPage = (Page<Supplier>) list;
        return new PageResult(supplierPage.getTotal(),supplierPage.getResult());
    }
}
